package com.example.shop.user.dao;

import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.example.shop.user.dto.UserPersonalInfoParam;
import com.example.shop.user.dto.UserQueryParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserPersonalInfoParamDao {
    @Update("<script>" +
            "update `user` set " +
            "<if test = 'updateInfo.userName != null'>" +
                "user_name = #{updateInfo.userName}, " +
            "</if>" +
            "<if test = 'updateInfo.userSex != null'>" +
                "user_sex = #{updateInfo.userSex}, " +
            "</if>" +
            "<if test = 'updateInfo.userArea != null'>" +
                "user_area = #{updateInfo.userArea}, " +
            "</if>" +
            "<if test = 'updateInfo.userDateBirth != null'>" +
                "user_date_birth = #{updateInfo.userDateBirth}, " +
            "</if>" +
            "<if test = 'updateInfo.userSignature != null'>" +
                "user_signature = #{updateInfo.userSignature}, " +
            "</if>" +
            "user_id = user_id " +
            "where " +
            UserQueryParam.QUERY_SQL+
            "</script>")
    int updateUser(@Param("updateInfo") UserPersonalInfoParam updateInfo,@Param(Constants.WRAPPER) UserQueryParam queryParam);
}
